package memnto.example;

import memnto.source.Memento;

/**
 * @author Chen Guang
 * @date 2019/4/17 0017 上午 10:23
 */
public class PlayRole {
    /**
     * 生命力
     */
    private int vitality;
    /**
     * 攻击力
     */
    private int attack;
    /**
     * 防御力
     */
    private int defence;

    public PlayRole(int vitality, int attack, int defence) {
        this.vitality = vitality;
        this.attack = attack;
        this.defence = defence;
    }

    public void setVitality(int vitality) {
        this.vitality = vitality;
    }


    public void setAttack(int attack) {
        this.attack = attack;
    }

    public void setDefence(int defence) {
        this.defence = defence;
    }

    /**
     * 状态显示
     */
    public void stateDisplay(){
        System.out.println("角色当前状态：");
        System.out.println("生命值：" + this.vitality);
        System.out.println("攻击力：" + this.attack);
        System.out.println("防御值：" + this.defence);
    }

    public RoleMemento saveRoleState(){
        return new RoleMemento(this.vitality, this.attack, this.defence);
    }

    public void fight(){
        System.out.println("战斗激烈");
        this.setVitality(20);
        this.setAttack(12);
        this.setDefence(0);
    }

    public void recoveryState(RoleMemento memento){
        this.setVitality(memento.getVitality());
        this.setAttack(memento.getAttack());
        this.setDefence(memento.getDefence());
    }


}
